package com.example.spzx.controller;

import com.example.spzx.Service.SysMenuService;
import com.example.spzx.model.entity.system.SysMenu;
import com.example.spzx.model.vo.common.Result;
import com.example.spzx.model.vo.common.ResultCodeEnum;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/system/sysMenu")
public class SysMenuController {
    @Resource
    private SysMenuService sysMenuService;
    @GetMapping("/findNodes")
    public Result<SysMenu> findNodes(){
        List<SysMenu> list=sysMenuService.findNodes();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }
    @PostMapping("/add")
    public Result<SysMenu> add(@RequestBody SysMenu sysMenu){
        sysMenuService.add(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @PostMapping("/updateById")
    public Result<SysMenu> updateById(@RequestBody SysMenu sysMenu){
        sysMenuService.update(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id){
        sysMenuService.delete(id);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
}
